<?php
/**
 * 温度、湿度显示脚本（Linux 终端有效）
 */
 
$c = include(__DIR__."/../config.php");

while (1) {

	echo shell_exec("clear");
	
	$redis = new Redis();
	$redis->connect($c['REDIS_HOST'], $c['REDIS_PORT']);
	$redis->select($c['REDIS_SELESE']);

	$temp = $redis->exists('TEMP%HOME')?$redis->get('TEMP%HOME'):0;
	$hum = $redis->exists('HUMIDITY%HOME')?$redis->get('HUMIDITY%HOME'):0;
	$ir = $redis->exists('IRTEMP%IRTEMP001')?$redis->get('IRTEMP%IRTEMP001'):0;

	echo shell_exec("figlet -W -f digital TEMP");
	echo shell_exec("figlet -W -f small $temp C");
	echo shell_exec("figlet -W -f digital HUMIDITY");
	echo shell_exec("figlet -W -f small $hum %");
	echo shell_exec("figlet -W -f digital IRTEMP");
	echo shell_exec("figlet -W -f small $ir C");
	
	$redis->close();
	unset($redis);
	sleep(5);

}
